package com.bluesky.plum.domain.repository.search.operator;

public enum StringOperator implements LogicOperator {
	Like {
		@Override
		Boolean _operate(String o1, String o2) {
			// %abc
			o2 = o2.replaceAll("%", ".*");
			//System.out.println("in StringOperator:"+o2);
			return (o1.matches(o2));
		}
	},
	Equals {
		@Override
		Boolean _operate(String o1, String o2) {

			return (o1.equalsIgnoreCase(o2));
		}
	};

	abstract Boolean _operate(String o1, String o2);

	@Override
	public Boolean operate(Object o1, Object o2) {

		return _operate((String) o1, (String) o2);
	}
	
	public static void main(String[] args) {
		System.out.println(StringOperator.Like._operate("AABBC",".*A"));
	}
}
